﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Microsoft.Win32;

namespace System.AutoUpdate.Gui
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class HashGenerator : Window
    {
        public HashGenerator()
        {
            InitializeComponent();
        }

        private void BrowseButtonClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog () == true)
            {
                HashAlgorithm algorithm = new SHA1CryptoServiceProvider();
                byte[] bytes = algorithm.ComputeHash (new FileStream (dialog.FileName, FileMode.Open));

                HashTextBox.Text = BitConverter.ToString (bytes).Replace ("-", "");
            }
        }
    }
}
